package com.bl.student.dao.repository;

import com.bl.student.dao.model.UserRecordEntity;
import com.bl.student.dao.model.UserShareEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

/**
 * Created by liangweikang on 20/8/1.
 */
public interface ShareRepository extends PagingAndSortingRepository<UserShareEntity, Integer> {

    List<UserShareEntity> findByUserId(int userId);

    @Query(value = "SELECT * FROM USER_SHARE GROUP BY user_id", nativeQuery = true)
    List<UserShareEntity> findGroupByUserId();

    List<UserShareEntity> findByUserIdAndUserRecordId(int userId ,int userRecordId);

    void deleteByUserIdAndUserRecordId(int userId ,int userRecordId);
}
